using System;
using System.Reflection;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

using Microsoft.Reporting.WinForms;

using MVPlan.Engine;
using MVPlan.Engine.Dive;
using MVPlan.Engine.Gases;
using MVPlan.Engine.Segment;
using MVPlan.Reporting;


namespace MVPlan.GUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            List<Gas> gases = new List<Gas>();
            List<SegmentDive> segments = new List<SegmentDive>();            

            gases.Add(new Gas(0.21, .35));
            gases.Add(new Gas(0.5, 0));
            //gases.Add(new Gas(1, 0));
            //gases.Add(new Gas(0.21, 0));

            segments.Add(new SegmentDive(50, 30, gases[0], 1.25));
            segments.Add(new SegmentDive(21, 0, gases[1], 1.6));
            //segments.Add(new SegmentDive(6, 0, gases[2], 0));

            //segments[1].Type = SegmentAbstract.WAYPOINT;

            //segments.Add(new SegmentDive(22, 0, gases[1], 0));

            Profile p = new Profile(segments, gases, null);

            p.IsOCDeco = false;

            switch ((ProfileStatus)p.DoDive())
            {
                case ProfileStatus.Success:

                    Assembly a = Assembly.GetAssembly(typeof(SegmentDataSet));

                    using (Stream r = a.GetManifestResourceStream("MVPlan.Reporting.SegmentReport.rdlc"))
                    {
                        this.reportViewer1.LocalReport.LoadReportDefinition(r);

                        ReportDataSource d = new ReportDataSource("SegmentDataSet_DiveSegment", SegmentReportManager.BuildDataSet(p).DiveSegment);
                        ReportDataSource d1 = new ReportDataSource("SegmentDataSet_DiveInfo", SegmentReportManager.BuildDataSet(p).DiveInfo);
                        ReportDataSource d2 = new ReportDataSource("SegmentDataSet_Contingency", SegmentReportManager.BuildDataSet(p).Contingency);
                        ReportDataSource d4 = new ReportDataSource("SegmentDataSet_DiveInfoOC", SegmentReportManager.BuildDataSet(p).DiveInfoOC);
                        ReportDataSource d3 = new ReportDataSource("SegmentDataSet_DiveSegmentOC", SegmentReportManager.BuildDataSet(p).DiveSegmentOC);
                        
                        this.reportViewer1.LocalReport.DataSources.Add(d);
                        this.reportViewer1.LocalReport.DataSources.Add(d1);
                        this.reportViewer1.LocalReport.DataSources.Add(d2);
                        this.reportViewer1.LocalReport.DataSources.Add(d3);
                        this.reportViewer1.LocalReport.DataSources.Add(d4);

                        List<ReportParameter> parameters = new List<ReportParameter>();

                        parameters.Add(new ReportParameter("ShowStopTime", Prefs.Current.ReportShowStopTime.ToString()));

                        parameters.Add(new ReportParameter("ShowBailout", Prefs.Current.ReportShowBailout.ToString()));

                        this.reportViewer1.LocalReport.SetParameters(parameters);


                        this.reportViewer1.RefreshReport();
                    }

                    break;
                case ProfileStatus.ProcessingError:
                    break;
                case ProfileStatus.InfiniteDeco:
                    break;
                case ProfileStatus.NothingToProcess:
                    break;
                case ProfileStatus.CeilingViolation:
                    break;
            }            



        }
    }
}